package org.exercise10.state;

import org.exercise10.state.DoorStatus;
import org.exercise10.state.State;
import org.exercise10.state.impl.*;

/**
 * @author Stranger
 * @version 1.0
 * @description: TODO
 * @date 2022/12/20 17:30
 */
public class Context {

    public static final ClosedState CLOSED_STATE = new ClosedState();

    public static final ClosingState CLOSING_STATE = new ClosingState();

    public static final OpenedState OPENED_STATE = new OpenedState();

    public static final StayOpenState STAY_OPEN_STATE = new StayOpenState();

    public static final OpeningState OPENING_STATE = new OpeningState();

    private DoorStatus state;

    public State getState() {
        return state;
    }

    public void setState(DoorStatus state) {
        this.state = state;
        this.state.setContext(this);
    }

    public Context() {
        this.setState(CLOSED_STATE);
    }

    public void open() {
        state.open();
    }

    public void close() {
        state.close();
    }

    public void stayOpen() {
        state.StayOpen();
    }

    public void touch() {
        state.touch();
    }
}
